package net.wexoo.onlinedivelog.reusable.panel;

import net.wexoo.onlinedivelog.reusable.behaviour.modifier.ClassAttributeModifier;
import net.wexoo.onlinedivelog.reusable.behaviour.modifier.ValueAttributeModifier;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.panel.Panel;

public abstract class AjaxLinkPanel extends Panel {

  private static final long serialVersionUID = 1L;

  public AjaxLinkPanel(String id, String valueString) {
    this(id, valueString, "default_button");
  }

  public AjaxLinkPanel(String id, String valueString, String cssClass) {
    super(id);

    AjaxLink<Void> ajaxLink = new AjaxLink<Void>("ajaxLink") {

      private static final long serialVersionUID = 1L;

      @Override
      public void onClick(AjaxRequestTarget target) {
        clickAction(target);
      }
    };
    ajaxLink.add(new ValueAttributeModifier(valueString));
    ajaxLink.add(new ClassAttributeModifier(cssClass));
    add(ajaxLink);
  }

  public abstract void clickAction(AjaxRequestTarget target);
}